package com.geline.easyexcel.utils;

import cn.hutool.json.JSONUtil;
import lombok.Getter;
import lombok.Setter;

/**
 * @author: mengxin
 * @date: 2024/2/1 10:49
 */
public class BeanFieldUtilDemo {

    @Getter
    @Setter
    public static class User{
        private String name;
        private char title2;
        private Integer age;
        private Float money;
    }

    public static void main(String[] args) throws IllegalAccessException {
        User user = new User();
        System.out.println(JSONUtil.toJsonStr(user));
        BeanFieldUtil.setDefaultValues(user, false);
        System.out.println(JSONUtil.toJsonStr(user));

        User user2 = new User();
        user2.setAge(100);
        user2.setMoney(0F);
        BeanFieldUtil.setDefaultValues(user2, false);
        System.out.println(JSONUtil.toJsonStr(user2));
        BeanFieldUtil.setDefaultValues(user2, true);
        System.out.println(JSONUtil.toJsonStr(user2));
    }
}
